<%@page import="cn.edu.thsis.pojo.User"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="cn.edu.thsis.dao.impl.jdbcUtils"%>
<%@page import="java.sql.Connection"%>
<%@page import="cn.edu.thsis.pojo.thsis"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>毕业论文选题系统-论文动态</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/font-awesome.css">
    <link rel="stylesheet" href="../css/animate.css">
    <link rel="stylesheet" href="../css/style.css">
</head>
<body class="gray-bg">
<div class="wrapper wrapper-content animated fadeIn">


    <div class="row">
        <div class="col-sm-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h5>论文动态</h5>
                </div>
                <div class="ibox-content">
                    <%
                    User user = (User)request.getSession().getAttribute("user");
                    Connection conn = jdbcUtils.getConnection();
                    String sql = "SELECT en.stu_id,en.accept,en.thsis_id,en.thsis_id,th.thsis_id,th.thsis_name FROM enrol en,thsis th WHERE en.thsis_id=th.thsis_id and stu_id=?";
                    PreparedStatement ps = conn.prepareStatement(sql);
        			ps.setString(1, user.getUid());
        			ResultSet rs = ps.executeQuery();
                    while(rs.next()){
                    Integer accept = rs.getInt("accept");
                    String stuId = rs.getString("stu_id");
                    if(!(stuId.equals(user.getUid()))){
                    %>
                    <div class="row">
                        <div class="col-sm-6">
                            <div class="panel panel-default">
                                <div class="panel-heading">你未预约论题</div>
                                <div class="panel-body">
                                    <p>请及时通过<strong>论文列表</strong>进行论题选择。</p>
                                </div>
                            </div>
                        </div>
                    </div>
                    <%}else if(accept.equals(1)){ %>
                    <div class="row">
                        <div class="col-sm-6">
                            <div class="panel panel-info">
                                <div class="panel-heading">预约成功</div>
                                <div class="panel-body">
                                    <p>你已成功预约论题，不过论题选择工作还没完成，请耐心<strong>等待导师反馈</strong>，及时关注论文动态，论题选定成功后该论题才属于你哦。</p>
                                </div>
                                <div class="panel-footer">预约成功论题：<%=rs.getString("thsis_name") %></div>
                            </div>
                        </div>
                    </div>
                    <%}else if(accept.equals(2)){ %>
                    <div class="row">
                        <div class="col-sm-6">
                            <div class="panel panel-success">
                                <div class="panel-heading"> 选定论题成功</div>
                                <div class="panel-body">
                                    <p>恭喜你，你已成功选定论题，可以开始准备论文的相关工作了！</p>
                                </div>
                                <div class="panel-footer">选定论题为：<%=rs.getString("thsis_name") %></div>
                            </div>
                        </div>
                    </div>
                    <%}else if(accept.equals(3)) {%>
                    <div class="row">
                        <div class="col-sm-6">
                            <div class="panel panel-warning">
                                <div class="panel-heading">
                                    <i class="fa fa-warning"></i> 论题预约失败</div>
                                <div class="panel-body">
                                    <p>恨遗憾，你预约的论题已被其他人选中，不要灰心，请重新预约其他论题。</p>
                                </div>
                                <div class="panel-footer">选定失败论题：<%=rs.getString("thsis_name") %></div>
                            </div>
                        </div>
                    </div>
                    <%}}%>
                </div>
            </div>
        </div>
    </div>
    <%
    Connection conn2 = jdbcUtils.getConnection();
    String sql2 = "SELECT warn FROM student WHERE uid =?";
    PreparedStatement ps2 = conn2.prepareStatement(sql2);
	ps2.setString(1, user.getUid());
	ResultSet rst = ps2.executeQuery();
    while(rst.next()){
    	Integer warn = rst.getInt("warn");
    	if(warn.equals(2)){%>
    	<div class="row">
        <div class="col-sm-12">
            <div class="ibox">
                <div class="ibox-title">
                    <h5>警告</h5>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-sm-6">
                            <div class="panel panel-warning">
                                <div class="panel-heading">
                                    <i class="fa fa-warning"></i> 请尽快完成选题操作</div>
                                <div class="panel-body">
                                    <p>请尽快完成选题操作，如不能按时完成，将严重影响毕业论文（设计）的开展，甚至不能顺利毕业！</p>
                                </div>
                            </div>
                        </div>
                    </div> 
                </div>
            </div>
        </div>
    </div>
    	<%}}%>
</div>
<!-- 全局js -->
<script src="../js/jquery.min.js"></script>
<script src="../js/bootstrap.min.js"></script>

<!-- 自定义js -->
<script src="../js/content.js"></script>
</body>
</html>